<?php

namespace app\portal\controller;

use app\admin\model\Paper;
use app\admin\model\Room;
use app\base\model\User;
use app\common\controller\PortalBase;
use think\Request;


class Index extends PortalBase {
  protected $modelRoom, $modelUser, $modelPaper;

  public function __construct(Request $request = NULL) {
    parent::__construct($request);
    $this->modelRoom = new Room();
    $this->modelUser = new User();
    $this->modelPaper = new Paper();
  }

  public function _initialize() {
    parent::_initialize();
  }

  public function index() {
    $userInfo = $this->modelUser->find($this->uid);
    $papers=$this->modelPaper->where('uid',$this->uid)->column('status,room_id','id');
    $roomIds=array_column($papers,'room_id');
    $rooms=$this->modelRoom->where('id','in',$roomIds)->paginate();

    $nowTimestamp = time();

    return view('', [
      'rooms'         => $rooms,
      'nowTimestamp' => $nowTimestamp,
    ]);
  }


}
